home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Samples / SampleCode / Tumbler and Podium / Tumbler_podium.c < prev    next >
Encoding:
Text File  |  1995-11-13  |  19.1 KB  |  693 lines  |  [TEXT/MPS ]

  1. // tumbler_podium.c -- this contains the podium specific routines for the tumbler app
  2. //
  3. //
  4.  
  5.  
  6. #ifdef PODIUM_APP
  7.  
  8. #include "QD3D.h"
  9.  
  10. #include <Drag.h>
  11. #include <Events.h>
  12. #include <Controls.h>
  13. #include <ToolUtils.h>
  14. #include <Windows.h>
  15.  
  16. #include "QD3DView.h"
  17. #include "QD3DDrawContext.h"
  18. #include "QD3DDrawContext.h"
  19. #include "QD3DPick.h"
  20. #include "QD3DGroup.h"
  21. #include "QD3DTransform.h"
  22. #include "QD3DLight.h"
  23. #include "QD3DMath.h"
  24.  
  25.  
  26. #include <QuickDraw.h>
  27. #include <QDOffscreen.h>
  28.  
  29.  
  30. #include "tumbler_Document.h"
  31. #include "tumbler_Camera.h"
  32. #include "tumbler_podium.h"
  33. #include "tumbler_offscreen.h"
  34. #include "tumbler_drag.h"
  35.  
  36.  
  37. static CursHandle        objectCursor, zoomInCursor, zoomOutCursor, handCursor;
  38.  
  39.  
  40. static TQ3Object DoHitTest(DocumentPtr    theDocument);
  41. static short PointInRect(Point *point, Rect *rect);
  42.  
  43. // Used in Tumber_AEVT.c
  44. void Podium_UpdateDrawContextFromDropRect( DocumentPtr theDocument ) ;
  45.  
  46. //------------------------------------------------------------------------------------
  47. void Podium_UpdateDrawContextFromDropRect( DocumentPtr theDocument )
  48. {
  49.  
  50.     Rect                    frameRect ;
  51.     PixMapHandle            hPixMap ;
  52.     Rect                    srcRect ;
  53.     TQ3PixmapDrawContextData    myDrawContextData ;
  54.     
  55.     frameRect = theDocument->dropArea ;
  56.      
  57.     // if the drop area for the doc is the same as the GWorld's rect
  58.     // then we don't need to do anything, if they have changes we need
  59.     // to update the drawcontext
  60.     
  61.     if(!EqualRect(&frameRect,&theDocument->geometriesOffscreen->portRect)) {
  62.         TQ3DrawContextObject    theDrawContext ;
  63.         OSErr                theErr ;
  64.         
  65.         if((theErr = UpdateGWorld( &theDocument->geometriesOffscreen, 32, &frameRect, nil, nil, 0L )) == noErr
  66. //            && (theErr = UpdateGWorld( &theDocument->maskOffscreen, 1, &frameRect, nil, nil, 0L )) == noErr
  67.             ) {    
  68.                         
  69.             theDrawContext = TumblerDocument_NewPixmapDrawContext( theDocument ) ;
  70.             Q3View_SetDrawContext(theDocument->theView, theDrawContext);
  71.             Q3Object_Dispose(theDrawContext);
  72.             
  73.             AdjustCamera(theDocument,
  74.                 theDocument->geometriesOffscreen->portRect.right - theDocument->geometriesOffscreen->portRect.left,
  75.                 theDocument->geometriesOffscreen->portRect.bottom - theDocument->geometriesOffscreen->portRect.top);
  76.         }
  77.     }
  78. }
  79.  
  80.         
  81.  
  82.  
  83.  
  84. static void MouseMoved(
  85.     DocumentPtr    theDocument,
  86.     long    oldX, 
  87.     long    oldY,
  88.     long    newX, 
  89.     long    newY)
  90. {
  91.     float                scaleFactor = 256.0;
  92.     unsigned long        winWidth, winHeight;
  93.     TQ3Matrix4x4            currentMatrix, tmp, newMatrix;
  94.     TQ3BoundingBox         viewBBox;
  95.     TQ3Point3D            modelCenter;
  96.     
  97.     /*
  98.      *  Find the bounding box for the group.
  99.      *  We'll use the center of the box as the point about which to rotate
  100.      *  (the old method always rotated about the world-space origin).
  101.      */
  102.  
  103.     /*
  104.      *  Get the width and height of the *current* window.
  105.      *  This is done so that mouse motion in a window has an effect
  106.      *  relative to the size of the window. 
  107.      */
  108.     winWidth  = theDocument->theWindow->portRect.right - theDocument->theWindow->portRect.left;
  109.     winHeight = theDocument->theWindow->portRect.bottom - theDocument->theWindow->portRect.top;
  110.  
  111.     GetGroupBBox(theDocument->theView, theDocument->documentGroup, NULL, &viewBBox);
  112.     
  113.     /*
  114.      *  The "to" point is the center of the view bounding box
  115.      */
  116.     {
  117.         float        weights[2] = { 0.5, 0.5 };
  118.         TQ3Point3D    points[2];
  119.         
  120.         points[0] = viewBBox.min;
  121.         points[1] = viewBBox.max;
  122.         
  123.         Q3Point3D_AffineComb(points, weights, 2, &modelCenter);
  124.     }
  125.             
  126.     /*
  127.      *  Make a new rotation matrix, rotating about the center of the view
  128.      *  bbox.
  129.      */            
  130.     {
  131.         float    xRot, yRot, zRot;
  132.         
  133.         xRot = yRot = zRot = 0.0;
  134.         
  135.         xRot = Q3Math_DegreesToRadians((float)(newY - oldY) / winHeight * scaleFactor);
  136.         yRot = Q3Math_DegreesToRadians((float)(newX - oldX) / winWidth * scaleFactor);
  137.  
  138.         if ((xRot != 0.0) || (yRot != 0.0)){
  139.             Q3Matrix4x4_SetRotateAboutPoint(&tmp, &modelCenter, xRot, yRot, zRot);
  140.             Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  141.         }
  142.     }
  143.  
  144. }
  145.  
  146.  
  147. static short PointInRect(Point *point, Rect *rect)
  148. {
  149.     if( point->h > rect->left && point->h < rect->right ) {
  150.         if( point->v > rect->top && point->v < rect->bottom ) {
  151.             return(1);
  152.         } else {
  153.             return(0);
  154.         }
  155.     } else {
  156.         return(0);
  157.     }
  158. }
  159.  
  160.  
  161. static Boolean PtOnHandles(Point *newMouse, Rect *location, short *whichHandle)
  162. {
  163.     Rect    handlesRect;
  164.     
  165.     handlesRect.left = location->left - 4;
  166.     handlesRect.top = location->top - 4;
  167.     handlesRect.right = location->left;
  168.     handlesRect.bottom = location->top;
  169.     
  170.     if( PointInRect(newMouse, &handlesRect) ) {
  171.         *whichHandle = LeftTopHandle;
  172.         return(true);
  173.     }
  174.     
  175.     handlesRect.left = location->right;
  176.     handlesRect.right = location->right + 4;
  177.     
  178.     if( PointInRect(newMouse, &handlesRect) ) {
  179.         *whichHandle = RightTopHandle;
  180.         return(true);
  181.     }
  182.     
  183.     handlesRect.left = location->right;
  184.     handlesRect.right = location->right + 4;
  185.     handlesRect.top = location->bottom;
  186.     handlesRect.bottom = location->bottom + 4;
  187.     
  188.     if( PointInRect(newMouse, &handlesRect) ) {
  189.         *whichHandle = RightBottomHandle;
  190.         return(true);
  191.     }
  192.     
  193.     handlesRect.left = location->left - 4;
  194.     handlesRect.right = location->left;
  195.     
  196.     if( PointInRect(newMouse, &handlesRect) ) {
  197.         *whichHandle = LeftBottomHandle;
  198.         return(true);
  199.     }
  200.     return(false);
  201. }
  202.  
  203. static void DrawHandles(Rect *location)
  204. {
  205.     Rect    handlesRect;
  206.     
  207.     handlesRect.left = location->left - 4;
  208.     handlesRect.top = location->top - 4;
  209.     handlesRect.right = location->left;
  210.     handlesRect.bottom = location->top;
  211.     
  212.     PaintRect(&handlesRect);
  213.     
  214.     handlesRect.left = location->right;
  215.     handlesRect.right = location->right + 4;
  216.     
  217.     PaintRect(&handlesRect);
  218.     
  219.     handlesRect.left = location->right;
  220.     handlesRect.right = location->right + 4;
  221.     handlesRect.top = location->bottom;
  222.     handlesRect.bottom = location->bottom + 4;
  223.     
  224.     PaintRect(&handlesRect);
  225.     
  226.     handlesRect.left = location->left - 4;
  227.     handlesRect.right = location->left;
  228.     
  229.     PaintRect(&handlesRect);
  230.     
  231.     PenSize(2,2);
  232.     MoveTo(location->left - 2, location->top - 2);
  233.     LineTo(location->right, location->top - 2);
  234.     LineTo(location->right, location->bottom);
  235.     LineTo(location->left - 2, location->bottom);
  236.     LineTo(location->left - 2, location->top - 2);
  237.     //FrameRect(location);
  238. }
  239.  
  240. /*
  241.  *    hit test a click in the document.
  242.  */
  243.  
  244. static TQ3Object DoHitTest(DocumentPtr    theDocument)
  245. {
  246.     TQ3WindowPointPickData    withData;
  247.     unsigned long        numPicked;
  248. //    TQ3RendererObject    saveRenderer;
  249.     TQ3PickObject        pickObject;
  250. //    TQ3DrawContextObject    drawCtx;
  251.     
  252.     withData.data.sort             =    kQ3PickSortNone;
  253.     withData.data.numHitsToReturn=    1;
  254.     withData.data.mask             =    kQ3PickDetailMaskObject;
  255.                                   
  256.     withData.point.x = theDocument->mouseLocation.h - theDocument->dropArea.left;
  257.     withData.point.y = theDocument->mouseLocation.v - theDocument->dropArea.top;
  258.  
  259.     withData.vertexTolerance = withData.edgeTolerance = 3;
  260. // this field gone in beta:    withData.view = theDocument->theView;
  261.  
  262.     pickObject = Q3WindowPointPick_New(&withData);
  263.  
  264.     //Q3View_GetRenderer(theDocument->theView, &saveRenderer);
  265.     //Q3View_GetDrawContext(theDocument->theView, &drawCtx);
  266.  
  267.     //Q3View_SetRendererByType(theDocument->theView, kQ3RendererTypeGeneric);
  268.     //Q3Object_Dispose(drawCtx);
  269.     
  270.     Q3View_StartPicking(theDocument->theView, pickObject );
  271.     do {
  272.         Q3DisplayGroup_Submit(theDocument->documentGroup, theDocument->theView);
  273.     } while (Q3View_EndPicking(theDocument->theView) == kQ3ViewStatusRetraverse);
  274.     
  275. //    Q3View_SetRenderer(theDocument->theView, saveRenderer);
  276.  
  277. //    Q3Object_Dispose(saveRenderer);
  278.     
  279.     if (Q3Pick_GetNumHits(pickObject, &numPicked) == kQ3Success && (numPicked != 0)) {
  280.         TQ3HitData hitData;
  281.         
  282.         // used to be: ErPick_GetFirstHit(pickObject, &hitData);
  283.         Q3Pick_GetHitData( pickObject, 1, &hitData );
  284.         Q3Object_Dispose(pickObject);
  285.         return(hitData.object);
  286.     } else {
  287.         Q3Object_Dispose(pickObject);
  288.         return(NULL);
  289.     }
  290.     
  291. }
  292.  
  293. /*
  294.  *    DoContent handles mouseDown events in the content region of a document window.
  295.  *
  296.  *    (1)    If the mouseDown is on a control, handle the click by calling TrackControl.
  297.  *
  298.  *    (2)    If the mouseDown is on a draggable object (the document's hiliteRgn) and a
  299.  *        successful drag occurs, no further processing is necessary.
  300.  *
  301.  *    (3)    If the mouseDown is on a draggable object and the mouse is released without
  302.  *        dragging, set the insertion point to the original mouseDown location by calling
  303.  *        TEClick with the mouseDown information.
  304.  *
  305.  *    (4)    If the mouseDown is not on a draggable object and within the viewRect of the
  306.  *        TextEdit field, call TEClick to handle the mouseDown.
  307.  */
  308.  
  309. void Podium_DoContent(DocumentPtr    theDocument, EventRecord *theEvent)
  310.  
  311. {    short            thePart;
  312.     Point            thePoint;
  313.     ControlHandle    theControl;
  314.  
  315.     SetPort(theDocument->theWindow);
  316.     thePoint = theEvent->where;
  317.  
  318.     if( theDocument->documentGroup ) {
  319.         Point     newMouse, offset;
  320.         short    whichHandle;
  321.         
  322.         GetMouse(&newMouse);
  323.         theDocument->mouseLocation = newMouse;
  324.         
  325.         /* First check for resize */
  326.         if( theDocument->currentlySelectedObject && PtOnHandles(&newMouse, &theDocument->dropArea, &whichHandle) ) {
  327.                 Rect    previousRect;
  328.                 Rect    frameRect;
  329.                 Point     oldMouse;
  330.                 TQ3Boolean    needRedraw;
  331.                 
  332.                 PenMode(srcXor);
  333.                 PenSize(2,2);
  334.                 frameRect = previousRect = theDocument->dropArea;
  335.                 
  336.                 oldMouse = theDocument->mouseLocation;
  337.                 switch( whichHandle ){
  338.                     case LeftTopHandle:
  339.                         
  340.                         offset.h = newMouse.h - frameRect.left;
  341.                         offset.v = newMouse.v - frameRect.top;
  342.  
  343.                         while (WaitMouseUp()) {
  344.                             GetMouse(&newMouse);
  345.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  346.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  347.                                     needRedraw = kQ3True;
  348.                                     frameRect.left = newMouse.h - offset.h;
  349.                                     frameRect.top = newMouse.v - offset.v;
  350.                                     DrawHandles(&previousRect);
  351.                                     DrawHandles(&frameRect);
  352.                                     previousRect = frameRect;
  353.                             }
  354.                         }
  355.                     break;
  356.                     case RightTopHandle:
  357.                         
  358.                         offset.h = newMouse.h - frameRect.right;
  359.                         offset.v = newMouse.v - frameRect.top;
  360.  
  361.                         while (WaitMouseUp()) {
  362.                             GetMouse(&newMouse);
  363.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  364.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  365.                                     needRedraw = kQ3True;
  366.                                     frameRect.right = newMouse.h - offset.h;
  367.                                     frameRect.top = newMouse.v - offset.v;
  368.                                     DrawHandles(&previousRect);
  369.                                     DrawHandles(&frameRect);
  370.                                     previousRect = frameRect;
  371.                             }
  372.                         }
  373.                     break;
  374.                     case LeftBottomHandle:
  375.                         
  376.                         offset.h = newMouse.h - frameRect.left;
  377.                         offset.v = newMouse.v - frameRect.bottom;
  378.  
  379.                         while (WaitMouseUp()) {
  380.                             GetMouse(&newMouse);
  381.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  382.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  383.                                     needRedraw = kQ3True;
  384.                                     frameRect.left = newMouse.h - offset.h;
  385.                                     frameRect.bottom = newMouse.v - offset.v;
  386.                                     DrawHandles(&previousRect);
  387.                                     DrawHandles(&frameRect);
  388.                                     previousRect = frameRect;
  389.                             }
  390.                         }
  391.                     break;
  392.                     case RightBottomHandle:
  393.                         
  394.                         offset.h = newMouse.h - frameRect.right;
  395.                         offset.v = newMouse.v - frameRect.bottom;
  396.  
  397.                         while (WaitMouseUp()) {
  398.                             GetMouse(&newMouse);
  399.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  400.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  401.                                     needRedraw = kQ3True;
  402.                                     frameRect.right = newMouse.h - offset.h;
  403.                                     frameRect.bottom = newMouse.v - offset.v;
  404.                                     DrawHandles(&previousRect);
  405.                                     DrawHandles(&frameRect);
  406.                                     previousRect = frameRect;
  407.                             }
  408.                         }
  409.                     break;
  410.                 }
  411.     
  412.                 theDocument->dropArea = frameRect;
  413.                 
  414.                 if( needRedraw == kQ3True ) {
  415.                     Podium_UpdateDrawContextFromDropRect( theDocument ) ;
  416.                     DrawOffscreen(theDocument);
  417.                     DrawOnscreen(theDocument);
  418.                     
  419.                 }
  420.                         
  421.                 PenMode(srcXor);
  422.                 PenSize(2,2);
  423.                 PenPat(&qd.black);
  424.                 DrawHandles(&frameRect);
  425.         /* is it in content */
  426.         } else if( PtInRect(newMouse, &theDocument->dropArea) ) {
  427. //            TQ3Object    newPick;
  428. //        if(( newPick = DoHitTest(theDocument)) != NULL) {
  429.             if( theDocument->selected == kQ3False) {
  430.                 PenMode(srcXor);
  431.                 PenSize(2,2);
  432.                 PenPat(&qd.black);
  433.                 DrawHandles(&theDocument->dropArea);
  434.             }
  435.             
  436.             theDocument->currentlySelectedObject = theDocument->documentGroup ;
  437.             
  438.             if( theEvent->modifiers & shiftKey )
  439.                 SetCursor(*zoomInCursor);
  440.             else if( theEvent->modifiers & cmdKey )
  441.                 SetCursor(*zoomOutCursor);
  442.             else
  443.                 SetCursor(*objectCursor);
  444.         
  445.             if( theEvent->modifiers & shiftKey ) {
  446.                 TQ3Matrix4x4    tmp;
  447.                 
  448.                 Q3Matrix4x4_SetScale(&tmp, 1.2, 1.2, 1.2);
  449.                 while (WaitMouseUp()) {
  450.                     Q3Matrix4x4_Multiply(&tmp, &theDocument->modelRotation, &theDocument->modelRotation);
  451.                     DrawOffscreen( theDocument ) ;
  452.                     DrawOnscreen( theDocument ) ;
  453.                 }
  454.             } else if( theEvent->modifiers & cmdKey ) {
  455.                 TQ3Matrix4x4    tmp;
  456.                 
  457.                 Q3Matrix4x4_SetScale(&tmp, 0.83333, 0.83333, 0.83333);
  458.                 while (WaitMouseUp()) {
  459.                     Q3Matrix4x4_Multiply(&tmp, &theDocument->modelRotation, &theDocument->modelRotation);
  460.                     DrawOffscreen(theDocument);
  461.                     DrawOnscreen( theDocument ) ;
  462.                 }
  463.             } else if( theEvent->modifiers & controlKey ) {
  464.             
  465.                 Point     oldMouse;
  466.                 Point     newMouse;
  467.                 long     mouseChanged = 0;
  468.                 long    dx, dy, x, y, oldX, oldY;
  469.                 float    width, height;
  470.                 float    xRot, yRot;
  471.                         
  472.                 SetCursor(*handCursor);
  473.                 GetMouse(&newMouse);        // get the mouse in local co-ordinates, 
  474.                                                 // local to the  current GrafPort
  475.         
  476.                 oldX = newMouse.h;
  477.                 oldY = newMouse.v;
  478.                 
  479.                 width = theDocument->geometriesOffscreen->portRect.right - theDocument->geometriesOffscreen->portRect.left;
  480.                 height =  theDocument->geometriesOffscreen->portRect.bottom - theDocument->geometriesOffscreen->portRect.top;
  481.     
  482.                 while (WaitMouseUp()) {
  483.                 
  484.                     GetMouse(&newMouse);        // get the mouse in local co-ordinates, 
  485.                                                 // local to the  current GrafPort
  486.     
  487.                     dx = newMouse.v - oldY;
  488.                     dy = newMouse.h - oldX;
  489.                     
  490.                     if ((dx != 0) || (dy != 0)) {
  491.                         TQ3Matrix4x4        tempMatrix;
  492.                         
  493.                         xRot = ((float) dx * kQ3Pi) / width;
  494.                         yRot = ((float) dy * kQ3Pi) / height;
  495.             
  496.                         if ((xRot != 0.0) || (yRot != 0.0)) {
  497.                             Q3Matrix4x4_SetRotate_XYZ(&tempMatrix, xRot, yRot, 0.0);
  498.                             Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tempMatrix, &theDocument->modelRotation);
  499.     
  500.                             mouseChanged = 1;
  501.                             DrawOffscreen(theDocument);
  502.                             DrawOnscreen( theDocument ) ;
  503.                         }
  504.                     }
  505.                     oldX = newMouse.h; oldY = newMouse.v;
  506.                 }
  507.                 
  508.                 if( mouseChanged ) {
  509.                     theDocument->rotationDir.x = xRot;
  510.                     theDocument->rotationDir.y = yRot;
  511.                 }
  512.             } else {
  513.                 Rect    previousRect;
  514.                 Rect    frameRect;
  515.                 Point     oldMouse;
  516.                 TQ3Boolean    needRedraw;
  517.                 long    height, width;
  518.                 
  519.                 PenMode(srcXor);
  520.                 PenSize(2,2);
  521.                 frameRect = previousRect = theDocument->dropArea;
  522.                 height = frameRect.bottom - frameRect.top;
  523.                 width = frameRect.right - frameRect.left;
  524.                 
  525.                 offset.h = newMouse.h - frameRect.left;
  526.                 offset.v = newMouse.v - frameRect.top;
  527.                 
  528.                 oldMouse = theDocument->mouseLocation;
  529.                 while (WaitMouseUp()) {
  530.                     GetMouse(&newMouse);
  531.                     if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  532.                         newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  533.                             needRedraw = kQ3True;
  534.                             frameRect.left = newMouse.h - offset.h;
  535.                             frameRect.top = newMouse.v - offset.v;
  536.                             frameRect.right = frameRect.left + width;
  537.                             frameRect.bottom = frameRect.top + height;
  538.                             DrawHandles(&previousRect);
  539.                             DrawHandles(&frameRect);
  540.                             previousRect = frameRect;
  541.                     }
  542.                 }
  543.     
  544.                 theDocument->dropArea = frameRect;
  545.                 
  546.                 if( needRedraw == kQ3True ) {
  547.                     Podium_UpdateDrawContextFromDropRect( theDocument ) ;
  548.                     DrawOffscreen(theDocument);
  549.                     DrawOnscreen(theDocument);
  550.                         
  551.                 }
  552.                 PenMode(srcXor);
  553.                 PenSize(2,2);
  554.                 PenPat(&qd.black);
  555.                 DrawHandles(&frameRect);
  556.             }
  557.         } else {
  558.             if( theDocument->selected == kQ3True) {
  559.                 theDocument->currentlySelectedObject = NULL;
  560.                 theDocument->selected = kQ3False;
  561.                 PenMode(srcXor);
  562.                 PenSize(2,2);
  563.                 PenPat(&qd.black);
  564.                 DrawHandles(&theDocument->dropArea);
  565.             }
  566.             SetCursor(&qd.arrow);
  567.         }
  568.     } 
  569.     else  {
  570.     
  571.         if( theDocument->currentlySelectedObject ) {
  572.             theDocument->currentlySelectedObject = NULL;
  573.             PenMode(srcXor);
  574.             PenSize(2,2);
  575.             DrawHandles(&theDocument->dropArea);
  576.             SetCursor(&qd.arrow);
  577.         }
  578.     }
  579. }
  580.  
  581.  
  582. /*
  583.  *    DoBackgroundContent handles mouseDown events in the content region of a document window
  584.  *    when the window is not frontmost. The following bullet items describe how this background
  585.  *    mouseDown event is handled:
  586.  *
  587.  *    (1)    If the mouseDown is not in a draggable object (not in the document's hiliteRgn) call
  588.  *        SelectWindow to bring the window to the front as usual.
  589.  *
  590.  *    (2)    If the mouseDown is in a draggable object and the mouse is released without
  591.  *        dragging, call SelectWindow when the mouse is released.
  592.  *
  593.  *    (3)    If the mouseDown is in a draggable object and a successful drag occurs, SelectWindow
  594.  *        should only be called if the drop occurred in the same window (the DragText function
  595.  *        calls SelectWindow in this case).
  596.  */
  597.  void Podium_DoBackgroundContent(DocumentPtr    theDocument, EventRecord *theEvent)
  598.  
  599. {    short            thePart;
  600.     Point            thePoint;
  601.     ControlHandle    theControl;
  602.     RgnHandle        tempRgn = NewRgn();  // Nick this needs to be the BBox of the group
  603.  
  604.     SetPort(theDocument->theWindow);
  605.     thePoint = theEvent->where;
  606.     GlobalToLocal(&thePoint);
  607.  
  608.     RectRgn(tempRgn, &theDocument->geometriesOffscreen->portRect);
  609.  
  610.     if (PtInRgn(thePoint,tempRgn)) {
  611.         if (! DoDragObjects(theDocument, theEvent, tempRgn)) {
  612.             SelectWindow(theDocument->theWindow);
  613.         }
  614.     } 
  615.     else {
  616.         SelectWindow(theDocument->theWindow);
  617.     }
  618.     
  619.     DisposeRgn(tempRgn);
  620. }
  621.  
  622.  
  623.  
  624.  
  625. /*
  626.  *    DoIdle get called repetitively while the application is not doing
  627.  *    anything.
  628.  */
  629.  
  630. void Podium_DoIdle(EventRecord *theEvent)
  631. {
  632.     WindowPtr        theWindow;
  633.     DocumentPtr    theDocument;
  634.  
  635.     if ((theWindow = FrontWindow()) != nil) {
  636.         if ((theDocument = GetDocumentFromWindow(theWindow)) != nil) {
  637.             SetPort(theDocument->theWindow);
  638.  
  639.             if( theDocument->documentGroup ) {
  640.                 Point     mouseLocation;
  641.                 
  642.                 GetMouse(&mouseLocation);
  643.  
  644.                  theDocument->mouseLocation = mouseLocation;
  645.                  
  646.                  if( PointInRect(&theDocument->mouseLocation, &theDocument->dropArea) ) {
  647.                     if(/*DoHitTest(theDocument)*/1) {
  648.                         if( theEvent->modifiers & shiftKey) {
  649.                             SetCursor(*zoomInCursor);
  650.                         } else if( theEvent->modifiers & cmdKey) {
  651.                             SetCursor(*zoomOutCursor);
  652.                         } else if( theEvent->modifiers & controlKey) {
  653.                             SetCursor(*handCursor);
  654.                         } else {
  655.                             SetCursor(*objectCursor);
  656.                         }
  657.                     } else {
  658.                         SetCursor(&qd.arrow);
  659.                     }
  660.                 } else {
  661.                     SetCursor(&qd.arrow);
  662.                 }
  663.                 
  664.                 if( theDocument->animateModel == kQ3True) {
  665.                     TQ3Matrix4x4    tmp;
  666.                     
  667.                     if( theDocument->rotationDir.x == 0.0 && theDocument->rotationDir.y == 0.0 ) {
  668.                         Q3Matrix4x4_SetRotate_XYZ(&tmp, 0.03, 0.08, 0.0);
  669.                         Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  670.                     } else {
  671.                         Q3Matrix4x4_SetRotate_XYZ(&tmp, theDocument->rotationDir.x, theDocument->rotationDir.y, 0.0);
  672.                         Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  673.                     }
  674.                     DrawOffscreen(theDocument);
  675.                     DrawOnscreen(theDocument);
  676.                 }
  677.             }
  678.         }
  679.     }
  680. }
  681.  
  682. void Podium_Init(void)
  683. {
  684.     objectCursor = GetCursor(132);
  685.     zoomInCursor = GetCursor(133);
  686.     zoomOutCursor = GetCursor(134);
  687.     handCursor = GetCursor(130);
  688. }
  689.  
  690.  
  691.  
  692. #endif /* PODIUM_APP */
  693.